package com.gem.mapper;


import com.gem.domain.Score;
import com.gem.domain.ScoreAPI;
import com.gem.domain.ScoreResult;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * @author Bravea❤ ·勇
 * Description: 学生成绩mapper
 * create
 * Modified By:
 */
@Mapper
public interface ScoreMapper {

    //查询指定班级所有学生成绩
    @Select("SELECT sc.*,s.s_name FROM score sc,student s WHERE sc.sid = s.s_id AND s_class_id = #{classId} AND s_status > 0 ")
    List<Score> showScore(Integer classId);

    //班级的指定学生成绩模糊搜索
    @Select("SELECT sc.*,s.s_name FROM score sc,student s WHERE sc.sid = s.s_id AND s_class_id = #{param1} AND s_name Like #{param2} AND s_status > 0 ")
    List<Score> searchScore(Integer cId,String sname);

    //@Insert("INSERT INTO score (sid,aver_grade,writ_grade,view_grade,project,up_grade,down_grade) VALUES (#{s_id},#{avgscore},#{wscore},#{fscore},#{competitiveproject},#{onlineprojectstatu},#{underlineprojectstatu})")
    @Insert("INSERT INTO score (sid) VALUES (#{api})")
    boolean add(Integer api);

    @Update("UPDATE score SET aver_grade=#{avgscore},writ_grade=#{wscore},view_grade=#{fscore},project=#{competitiveproject},up_grade=#{onlineprojectstatu},down_grade=#{underlineprojectstatu} WHERE sid=#{s_id}")
    boolean update(ScoreAPI api);

    @Update("UPDATE score SET resume=#{resume},result=#{result} WHERE sid=#{sid}")
    boolean updateMy(ScoreResult list);
}
